#!/bin/bash
set -eu

DIR="$(dirname "$0")"

function usage() {
    echo -n \
"Usage: $(basename "$0") SERVICE COMMAND[S]
Use Docker Compose to run a command for a service, or drop into a console.

Example: ./scripts/console gt-transit \"./sbt\"
"
}


if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
    if [ "${1:-}" = "--help" ]
    then
        usage
    else
    	if [ "${1:-}" = "--geodocker" ]
	    then
	        docker-compose -f "${DIR}/../docker-compose.geodocker.yml" \
	                       run --rm --service-ports --entrypoint \
	                       "/bin/bash -c" "$1" "${@:2}"
	    else
	        docker-compose -f "${DIR}/../docker-compose.yml" \
	                       run --rm --service-ports --entrypoint \
	                       "/bin/bash -c" "$1" "${@:2}"
	    fi
    fi
fi
